﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace HZY.Admin.Controllers.Sys
{
    using HZY.Logic.Sys;
    using HZY.Models.Sys;
    using HZY.DTO;
    using HZY.DTO.Sys;

    public class RoleFunctionController : ApiBaseController
    {

        protected Sys_RoleMenuFunctionLogic logic { get; }

        public RoleFunctionController(Sys_RoleMenuFunctionLogic _logic)
        {
            this.logic = _logic;
        }

        #region 基础 CURD

        ///// <summary>
        ///// 查询数据列表
        ///// </summary>
        ///// <param name="Page"></param>
        ///// <param name="Rows"></param>
        ///// <param name="Search"></param>
        ///// <returns></returns>
        //[HttpPost("FindList/{Page}/{Rows}"), Core.HZYApiAuthorizationCheckFilter]
        //public async Task<IActionResult> FindListAsync(int Page, int Rows, [FromBody] Sys_Role Search)
        //{
        //    var tableVM = await this.logic.FindListAsync(Page, Rows, Search);
        //    return this.StatusCodeOK( tableVM);
        //}

        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns></returns>
        [HttpPost("Save"), Core.HZYApiAuthorizationCheckFilter]
        public async Task<IActionResult> SaveAsync([FromBody]Sys_RoleMenuFunctionDto Model)
        {
            await this.logic.SaveAsync(Model);
            return this.StatusCodeOK();
        }

        ///// <summary>
        ///// 删除数据
        ///// </summary>
        ///// <param name="Ids"></param>
        ///// <returns></returns>
        //[HttpPost("Delete"), Core.HZYApiAuthorizationCheckFilter]
        //public async Task<IActionResult> DeleteAsync(List<Guid> Ids)
        //{
        //    await this.logic.DeleteAsync(Ids);
        //    return this.StatusCodeOK();
        //}

        ///// <summary>
        ///// 根据Id 加载表单数据
        ///// </summary>
        ///// <param name="Id"></param>
        ///// <returns></returns>
        //[HttpPost("LoadForm/{Id}"), Core.HZYApiAuthorizationCheckFilter]
        //public async Task<IActionResult> LoadFormAsync(Guid Id)
        //{
        //    await this.logic.LoadFormAsync(Id);
        //    return this.StatusCodeOK();
        //}

        #endregion

        #region 其他

        /// <summary>
        /// 获取菜单功能树
        /// </summary>
        /// <returns></returns>
        [HttpPost("Tree/{RoleId}"), Core.HZYApiAuthorizationCheckFilter]
        public async Task<IActionResult> Tree(Guid RoleId)
        {
            var tree = await this.logic.GetRoleMenuFunctionTreeAsync(RoleId);

            return this.StatusCodeOK(tree);
        }

        #endregion



    }
}